package com.yundasys.lab08jvm.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author jiangta
 * @version 1.0
 * @date 2021/7/1 9:46 上午
 */
public class MyThreadPoolDemo {

    public static void main(String[] args) {
        //Array Arrays(辅助工具类）
        //Collection Collections（辅助工具类）
        //Executor Executors（辅助工具类）

        // 一池5个处理线程（用池化技术，一定要记得关闭）
        ExecutorService threadPool = Executors.newFixedThreadPool(5);
        try {
            for (int i = 0; i < 10; i++) {
                final int tempInt = i;
                threadPool.execute(() -> {
                    System.out.println(Thread.currentThread().getName() + "\t 给用户:" + tempInt + " 办理业务");
                });
            }

        } catch (Exception e) {

        } finally {
            threadPool.shutdown();
        }

    }
}
